Server-Side Request Forgery (SSRF) — OWASP A10:2021

A detailed guide on understanding, exploiting, and mitigating SSRF vulnerabilities in web applications.

Understanding Server-Side Request Forgery (SSRF)

What is SSRF?

Server-Side Request Forgery occurs when an attacker manipulates a vulnerable web application to make HTTP requests to an unintended destination. These requests originate from the server itself, allowing attackers to access internal resources that are typically inaccessible externally.

How SSRF Works

Common SSRF Targets

Common SSRF Attack Payloads

Mitigation Strategies

Securing AWS Against SSRF

Implement Instance Metadata Service Version 2 (IMDSv2) to mitigate SSRF risks:

  1. Step 1: Get Token (PUT Request): PUT /latest/api/token with header X-aws-ec2-metadata-token-ttl-seconds.
  2. Step 2: Access Metadata (GET Request): GET /latest/meta-data/iam/security-credentials/ with header X-aws-ec2-metadata-token containing the token from Step 1.

This prevents simple SSRF GET attacks by requiring a session-based token, making exploitation significantly harder.

Key Takeaway

SSRF is a high-risk vulnerability that can expose internal resources and cloud credentials. Proper input validation, strict allow lists, network segmentation, and cloud-specific protections like IMDSv2 are essential for defense-in-depth against SSRF attacks.